home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / AIncludes / SCSI.a < prev    next >
Encoding:
Text File  |  1993-11-30  |  11.8 KB  |  356 lines  |  [TEXT/MPS ]

  1. ;    File:        SCSI.a
  2. ;
  3. ;    Copyright:    © 1983-1993 by Apple Computer, Inc.
  4. ;                All rights reserved.
  5. ;
  6. ;    Version:    System 7.1 for ETO #11
  7. ;    Created:    Tuesday, March 30, 1993 18:00
  8. ;
  9. ;___________________________________________________________________________
  10.  
  11.     IF &TYPE('__INCLUDINGSCSI__') = 'UNDEFINED' THEN
  12. __INCLUDINGSCSI__    SET    1
  13.  
  14.     IF &TYPE('__INCLUDINGTRAPS__') = 'UNDEFINED' THEN
  15.                     INCLUDE 'Traps.a'
  16.     ENDIF
  17.     
  18. ; misc SCSI driver equates
  19.  
  20. scMacID           EQU         $80                       ; SCSI ID for Macintosh Plus (bit 7)
  21. SCSIDrvrs         EQU         $B2E                      ; (word) bitmap for loaded SCSI drivers
  22.  
  23. ; SCSI error codes
  24.  
  25. scCommErr         EQU         2                         ; communications error (operation timeout)
  26. scArbNBErr        EQU         3                         ; arbitration timeout waiting for not BSY
  27. scBadparmsErr     EQU         4                         ; bad parameter or TIB opcode
  28. scPhaseErr        EQU         5                         ; SCSI bus not in correct phase for attempted operation
  29. scCompareErr      EQU         6                         ; data compare error
  30. scMgrBusyErr      EQU         7                         ; SCSI Manager busy with another operation
  31. ; when SCSIGet was called
  32.  
  33. scSequenceErr     EQU         8                         ; attempted operation is out of sequence;
  34. ; e.g., calling SCSISelect before doing
  35. ; SCSIGet. Incorrectly written drivers
  36. ; can cause this error.
  37.  
  38. scBusTOErr        EQU         9                         ; CPU bus timeout when attempting read or
  39. ; write in pseudo-DMA mode -- indicates
  40. ; that the data wasn't ready within the
  41. ; 'bus timeout' period. (Mac SE & Mac II only)
  42.  
  43. scComplPhaseErr   EQU         10                        ; SCSI bus wasn't in Status phase when
  44. ; SCSIComplete was called -- the SCSI
  45. ; Manager may have had to throw away data
  46. ; (or write 'filler' bytes) in order to
  47. ; reach the Status phase. Indicates that
  48. ; the driver didn't handle SCSI bus phase
  49. ; changes correctly.
  50.  
  51.  
  52. ; misc SCSI driver equates
  53.  
  54. scDefaultID       EQU         7                         ; default CPU SCSI id
  55.  
  56. ;---------------------------------------------------
  57. ;
  58. ; the information pertaining to the read/write
  59. ; command block interpreter.
  60. ;
  61. ; SCSI command block equates.
  62. ;
  63.  
  64. scOpcode          EQU         0                         ; offsets into command "line" for data xfer
  65. scParam1          EQU         2
  66. scParam2          EQU         6
  67. scSize            EQU         10                        ; size of a command line
  68.  
  69.  
  70. scInc             EQU         1                         ; xfer with address increment
  71. scNoInc           EQU         2                         ; xfer without address increment
  72. scAdd             EQU         3                         ; add count to address
  73. scMove            EQU         4                         ; MOVE data from addr1 to addr2
  74. scLoop            EQU         5                         ; decrement loop counter and branch
  75. scNop             EQU         6                         ; do very little
  76. scStop            EQU         7                         ; then stop doing even that
  77. scComp            EQU         8                         ; compare bytes with address increment
  78.  
  79. ;
  80. ; The layout of block 0 of a bootable SCSI device.
  81. ;
  82.  
  83. sbSigWord         EQU         $4552                     ; block 0 validator
  84. sbSig             EQU         0                         ; signature word
  85. sbBlkSize         EQU         2                         ; block size of device
  86. sbBlkCount        EQU         4                         ; # blocks on device
  87. sbDevType         EQU         8                         ; device type code
  88. sbDevID           EQU         10
  89. sbData            EQU         12                        ; start of data section
  90. sbDrvCount        EQU         16                        ; # drivers following
  91. sbDrvrs           EQU         18                        ; start of driver descriptors
  92.  
  93. ; Driver descriptors
  94.  
  95. ddBlock           EQU         0                         ; physical block of driver
  96. ddSize            EQU         4                         ; block count of driver
  97. ddType            EQU         6                         ; Processor type of driver
  98. ddLen             EQU         8
  99. sbMac             EQU         1                         ; Macintosh driver type
  100.  
  101. ;
  102. ; Partition Descriptors
  103. ;
  104. pdSigWord         EQU         $5453                     ; block 1 validator
  105. pmSig             EQU         0                         ; unique value for map entry blk
  106. pmSigPad          EQU         2                         ; currently unused
  107. pmMapBlkCnt       EQU         4                         ; # of blks in partition map
  108. pmPyPartStart     EQU         8                         ; first physical block of partition
  109. pmPartBlkCnt      EQU         12                        ; number of blocks in partition
  110. pmPartName        EQU         16                        ; ASCII partition name
  111. pmParType         EQU         48                        ; ASCII partition type
  112. pmLgDataStart     EQU         80                        ; log. # of partition's 1st data blk
  113. pmDataCnt         EQU         84                        ; # of blks in partition's data area
  114. pmPartStatus      EQU         88                        ; bit field for partition status
  115. pmLgBootStart     EQU         92                        ; logical blk of partition's boot code
  116. pmBootSize        EQU         96                        ; number of bytes in boot code
  117. pmBootAddr        EQU         100                       ; memory load address of boot code
  118. pmBootAddr2       EQU         104                       ; currently unused
  119. pmBootEntry       EQU         108                       ; entry point of boot code
  120. pmBootEntry2      EQU         112                       ; currently unused
  121. pmBootCksum       EQU         116                       ; checksum of boot code
  122. pmProcessor       EQU         120                       ; ASCII for the processor type
  123. pmPad             EQU         124                       ; 512 bytes long, currently unused
  124.  
  125.  
  126. hfsID             EQU         'TFS1'                    ; The HFS filesystem ID
  127.  
  128. ;Routine Selectors
  129.  
  130. scsiReset         EQU         0
  131. scsiGet           EQU         1
  132. scsiSelect        EQU         2
  133. scsiCmd           EQU         3
  134. scsiComplete      EQU         4
  135. scsiRead          EQU         5
  136. scsiWrite         EQU         6
  137. scsiInstall     EQU         7
  138. scsiRBlind        EQU         8
  139. scsiWBlind        EQU         9
  140. scsiStat          EQU         10
  141. scsiSelAtn        EQU         11
  142. scsiMsgIn         EQU         12
  143. scsiMsgOut        EQU         13
  144. numSelectors      EQU         14
  145.  
  146.  
  147.                   MACRO
  148.                   _SCSIReset
  149.                   MOVE        #scsiReset,-(sp)
  150.                   _SCSIDispatch
  151.                   ENDM
  152.  
  153.                   MACRO
  154.                   _SCSIGet
  155.                   MOVE        #scsiGet,-(sp)
  156.                   _SCSIDispatch
  157.                   ENDM
  158.  
  159.                   MACRO
  160.                   _SCSISelect
  161.                   MOVE        #scsiSelect,-(sp)
  162.                   _SCSIDispatch
  163.                   ENDM
  164.  
  165.                   MACRO
  166.                   _SCSICmd
  167.                   MOVE        #scsiCmd,-(sp)
  168.                   _SCSIDispatch
  169.                   ENDM
  170.  
  171.                   MACRO
  172.                   _SCSIComplete
  173.                   MOVE        #scsiComplete,-(sp)
  174.                   _SCSIDispatch
  175.                   ENDM
  176.  
  177.                   MACRO
  178.                   _SCSIRead
  179.                   MOVE        #scsiRead,-(sp)
  180.                   _SCSIDispatch
  181.                   ENDM
  182.  
  183.                   MACRO
  184.                   _SCSIWrite
  185.                   MOVE        #scsiWrite,-(sp)
  186.                   _SCSIDispatch
  187.                   ENDM
  188.  
  189.                   MACRO
  190.                   _SCSIInstall
  191.                   MOVE        #scsiInstall,-(sp)
  192.                   _SCSIDispatch
  193.                   ENDM
  194.  
  195.                   MACRO
  196.                   _SCSIRBlind
  197.                   MOVE        #scsiRBlind,-(sp)
  198.                   _SCSIDispatch
  199.                   ENDM
  200.  
  201.                   MACRO
  202.                   _SCSIWBlind
  203.                   MOVE        #scsiWBlind,-(sp)
  204.                   _SCSIDispatch
  205.                   ENDM
  206.  
  207.                   MACRO
  208.                   _SCSIStat
  209.                   MOVE        #scsiStat,-(sp)
  210.                   _SCSIDispatch
  211.                   ENDM
  212.  
  213.  
  214.                   MACRO
  215.                   _scsiSelAtn
  216.                   MOVE        #scsiSelAtn,-(sp)
  217.                   _SCSIDispatch
  218.                   ENDM
  219.  
  220.                   MACRO
  221.                   _SCSIMsgIn
  222.                   MOVE        #scsiMsgIn,-(sp)
  223.                   _SCSIDispatch
  224.                   ENDM
  225.  
  226.                   MACRO
  227.                   _SCSIMsgOut
  228.                   MOVE        #scsiMsgOut,-(sp)
  229.                   _SCSIDispatch
  230.                   ENDM
  231.  
  232. ;
  233. ;    New SCSI Manager
  234.  
  235. ;
  236. ;    SCSI request parameter block
  237. ;
  238. scsiPB            RECORD      0, INCREMENT
  239. scsiQLink         DS.L        1                         ; --- link to next request block                        
  240. scsiPrivate       DS.L        1                         ; --- SCSI Mgr private storage
  241. scsiVersion       DS.W        1                         ; --> version of the parameter block
  242. scsiBus           DS.W        1                         ; --> SCSI bus number
  243. scsiReqID         DS.B        1                         ; --> SCSI ID
  244. scsiReqLUN        DS.B        1                         ; --> logical unit number
  245. scsiResult        DS.W        1                         ; <-- return code from SCSI Manager
  246. scsiCompletion    DS.L        1                         ; --> address of completion routine
  247. scsiUsrData       DS.L        1                         ; --> pointer to user's storage
  248. scsiReqTO         DS.L        1                         ; --> in ms
  249. scsiUsrFlags      DS.W        1                         ; --> user's operation flag bits
  250. scsiSelTO         DS.W        1                         ; --> in ms
  251. scsiMgrFlags      DS.L        1                         ; --> SCSI operation flags
  252. scsiLinkCmd       DS.L        1                         ; --> ptr to next linked command
  253. scsiSnsBuf        DS.L        1                         ; --> sense buffer pointer
  254. scsiSnsLen        DS.B        1                         ; --> length of sense buffer ( at least 4 bytes )
  255. scsiSnsXfer       DS.B        1                         ; <-- actual sense bytes transferred
  256. scsiStatus        DS.B        1                         ; --> SCSI status byte
  257. scsiCmdLen        DS.B        1                         ; --> length of the command buffer
  258. scsiCmdBuf        DS.L        1                         ; --> command buffer pointer
  259. scsiDCInstr       DS.L        1                         ; --> ptr to array of data-chaining instructions
  260. scsiDataLen       DS.L        1                         ; --> requested data transfer length
  261. scsiDataXfer      DS.L        1                         ; <-- actual data bytes transferred
  262. scsiPBSize        EQU         *-scsiPB                  ; size of SCSI request parameter block
  263.                   ENDR
  264.  
  265. ;
  266. ;    flags
  267. ;
  268. ;    SCSI Mgr flags:
  269. ;
  270. scsiFParity       EQU         $00000001                 ; Enable parity checking
  271. scsiFNoDisc       EQU         $00000002                 ; Disconnection not allowed for this request
  272. scsiFWrite        EQU         $00000004                 ; output data to the SCSI bus
  273. scsiFFast         EQU         $00000008                 ; Transfer data in the "fast" mode
  274. scsiFPhysical     EQU         $00000010                 ; physical addresses are used (enables DMA)
  275. scsiFAsync        EQU         $00000020                 ; asynchronous request
  276. scsiFBusDevRst    EQU         $00000040                 ; attempt to send a Bus Device Reset message
  277. scsiFImmed        EQU         $00000080                 ; Immediate ("page fault") service requested
  278. ;    SCSI Mgr bits:
  279. scsiBParity       EQU         0                         ; enable parity checking
  280. scsiBNoDisc       EQU         1                         ; disconnection not allowed for this request
  281. scsiBWrite        EQU         2                         ; output data to the SCSI bus
  282. scsiBFast         EQU         3                         ; transfer data in the "fast" mode
  283. scsiBPhysical     EQU         4                         ; physical addresses are used (enables DMA)
  284. scsiBAsync        EQU         5                         ; asynchronous request
  285. scsiBBusDevRst    EQU         6                         ; attempt to send a Bus Device Reset message
  286. scsiBImmed        EQU         7                         ; Immediate ("page fault") service requested
  287.  
  288. ;
  289. ;    Data-chaining related equates
  290. ;                                
  291. dcLoop            EQU         -1                        ; loop opcode        (dcLoop,count,offset,store)
  292. dcStop            EQU         0                         ; stop opcode        (dcStop,-----,------,-----)
  293. ;                                ; move opcode        ( addr ,count,offset,store)
  294. dcInstr           RECORD      0, INCREMENT
  295. dcAddr            DS.L        1                         ; buffer start address    (0,-1,other)
  296. dcCount           DS.L        1                         ; generic count
  297. dcOffset          DS.L        1                         ; generic "offset"
  298. dcStore           DS.L        1                         ; used to create "Saved Data Pointer"
  299. dcSize            EQU         *-dcInstr                 ; size of one data-chaining instruction
  300.                   ENDR
  301.  
  302. ;
  303. ;    Status byte equates
  304. ;
  305. statusInitial     EQU         $FF                       ; initial "invalid" status byte value
  306. statusByteCode    EQU         $9E                       ; mask to clear vendor-unique bits in status byte
  307. statusRsrvBit     EQU         7                         ; reserved bit in status byte (must be zero for autosense)
  308. statusGood        EQU         $00                       ; status byte values with VU and reserved bits masked
  309. statusChkCond     EQU         $02
  310. statusCondMetGood EQU         $04
  311. statusBusy        EQU         $08
  312. statusIntGood     EQU         $10
  313. statusIntCMGood   EQU         $14
  314. statusRsrvConflict EQU        $18
  315.  
  316. ;
  317. ;    error codes on the original call
  318. ;
  319. scsiBadPBErr      EQU         -470                      ; invalid field(s) in the parameter block    
  320. ;
  321. ;    error codes in the "scsiResult" field
  322. ;
  323. scsiOverrunErr    EQU         -471                      ; attempted to transfer too many bytes    
  324. scsiTransferErr   EQU         -472                      ; write flag conflicts with data transfer phase 
  325. scsiBusTOErr      EQU         -473                      ; bus error during transfer 
  326. scsiSelectTOErr   EQU         -474                      ; scsiSelTO exceeded (selection failed) 
  327. scsiTimeOutErr    EQU         -475                      ; scsiReqTO exceeded
  328. scsiBusResetErr   EQU         -476                      ; the bus was reset, so your request was aborted
  329. scsiBadStatus     EQU         -477                      ; non-zero (not "Good") status returned 
  330. scsiNoStatusErr   EQU         -478                      ; device did not go through a status phase    
  331. scsiLinkFailErr   EQU         -479                      ; linked command never executed     
  332. scsiUnimpVctErr   EQU         -489                      ; unimplemented routine was called        
  333. ;
  334. ;    "in progress" codes in the "scsiResult" field
  335. ;
  336. scsiEnqueued      EQU         $0001                     ; enqueued, waiting to start
  337. scsiArbitrated    EQU         $0002                     ; arbitration in progress, or attempted
  338. scsiSelection     EQU         $0003                     ; selection in progress, or target selected
  339. scsiDisc          EQU         $0004                     ; disconnected
  340. scsiDataOut       EQU         $0010                     ; Data Out phase
  341. scsiDataIn        EQU         $0011                     ; Data In phase
  342. scsiCommand       EQU         $0012                     ; Command phase
  343. scsiStatus        EQU         $0013                     ; Status phase
  344. scsiIllegal1      EQU         $0014                     ; Unknown (illegal) phase
  345. scsiIllegal2      EQU         $0015                     ; Unknown (illegal) phase
  346. scsiMessageOut    EQU         $0016                     ; Message Out phase
  347. scsiMessageIn     EQU         $0017                     ; Message In phase
  348.  
  349. ;
  350. ;    SCSIBusInfo information selectors
  351. ;
  352. scsiIntfLvl       EQU         0                         ; SCSI Mgr interface level (1-n)
  353. scsiBusTO         EQU         1                         ; byte-to-byte time limit (in us, 0=no timeout)
  354. scsiBusDMA        EQU         2                         ; bus has a dedicated DMA channel (1=has DMA)
  355.  
  356.     ENDIF    ; ...already included